// helper.js
export function extractPermissions(idToExtract) {
    const storedMenuData = window.sessionStorage.getItem('menuData');

    if (!storedMenuData) {
        return [];
    }

    const menuData = JSON.parse(storedMenuData);
    const permissions = [];

    menuData.forEach(menuItem => {
        if (menuItem.children) {
            menuItem.children.forEach(childItem => {
                if (childItem.id === idToExtract) {
                    childItem.permissions.forEach(permission => {
                        permissions.push(permission.name);
                    });
                }
            });
        }
    });

    return permissions;
}